package com.aiyige.page.publish.traingclass.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.aiyige.city.model.City;
import com.aiyige.model.moment.backup.CardBackup;
import com.aiyige.model.moment.backup.TagBackup;
import com.aiyige.model.moment.entity.Guarantee;
import com.aiyige.model.moment.entity.Moment;
import com.aiyige.model.moment.entity.TrainingCourse;
import com.aiyige.page.publish.coursedescription.model.CourseCover;
import com.aiyige.page.publish.coursedescription.model.CourseDescriptionModel;
import com.aiyige.page.publish.courseschedule.model.CourseScheduleModel;
import com.aiyige.page.publish.guarantee.model.GuaranteeItem;
import com.aiyige.page.publish.selectinterest.model.PublishIndustryItem;
import com.aiyige.page.publish.selectinterest.model.PublishInterestItem;
import com.aiyige.page.publish.selectlearntarget.model.SelectLearnTargetItem;
import com.aiyige.page.publish.selectsuitablelearnage.model.SuitableLearnAgeItem;
import com.aiyige.page.publish.selectsuitablepeople.model.SelectSuitablePeopleItem;
import com.aiyige.page.publish.selecttag.model.SelectTagItem;
import com.aiyige.page.publish.selecttraingcard.model.TraingCard;
import com.aiyige.page.publish.util.PublishUtil;
import com.aiyige.setup.util.SetupUtil;
import com.aiyige.utils.DummyDataUtil;
import com.aiyige.utils.StringUtils;
import com.alibaba.fastjson.JSON;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by zhuyakun on 2018/3/20.
 */

public class TraingClassFormModel implements Parcelable {
    public static final int OPEN_CLASS_CONDITION_DEPEND_ON_POPULATION = 1;
    public static final int OPEN_CLASS_CONDITION_DEPEND_ON_OPEN_DATE = 2;
    String goodsId;
    String title;
    PublishInterestItem publishInterestItem;
    Boolean openBuy;
    String classSize;
    Integer openClassCondition;
    String minClassSize;
    Long confirmDate;
    Long startClassDate;
    Long endClassDate;
    ClassLocation classLocation;
    List<SuitableLearnAgeItem> suitableLearnAgeItemList;
    List<SelectLearnTargetItem> selectLearnTargetItemList;
    SelectSuitablePeopleItem selectSuitablePeopleItem;
    List<SelectTagItem> selectTagItemList;
    String price;
    String platformDividend;
    String courseNumber;
    List<TraingCard> traingCardList;
    String singlePrice;
    CourseDescriptionModel courseDescriptionModel;
    CourseCover cover;
    CourseScheduleModel courseScheduleModel;
    int operationType;
    String singleClassDuration;
    List<GuaranteeItem> guaranteeItemList;

    public TraingClassFormModel() {
    }

    private TraingClassFormModel(Builder builder) {
        setGoodsId(builder.goodsId);
        setTitle(builder.title);
        setPublishInterestItem(builder.publishInterestItem);
        setOpenBuy(builder.openBuy);
        setClassSize(builder.classSize);
        setOpenClassCondition(builder.openClassCondition);
        setMinClassSize(builder.minClassSize);
        setConfirmDate(builder.confirmDate);
        setStartClassDate(builder.startClassDate);
        setEndClassDate(builder.endClassDate);
        setClassLocation(builder.classLocation);
        setSuitableLearnAgeItemList(builder.suitableLearnAgeItemList);
        setSelectLearnTargetItemList(builder.selectLearnTargetItemList);
        setSelectSuitablePeopleItem(builder.selectSuitablePeopleItem);
        setSelectTagItemList(builder.selectTagItemList);
        setPrice(builder.price);
        setPlatformDividend(builder.platformDividend);
        setCourseNumber(builder.courseNumber);
        setTraingCardList(builder.traingCardList);
        setSinglePrice(builder.singlePrice);
        setCourseDescriptionModel(builder.courseDescriptionModel);
        setCover(builder.cover);
        setCourseScheduleModel(builder.courseScheduleModel);
        setOperationType(builder.operationType);
        setSingleClassDuration(builder.singleClassDuration);
        setGuaranteeItemList(builder.guaranteeItemList);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public PublishInterestItem getPublishInterestItem() {
        return publishInterestItem;
    }

    public void setPublishInterestItem(PublishInterestItem publishInterestItem) {
        this.publishInterestItem = publishInterestItem;
    }

    public Boolean getOpenBuy() {
        return openBuy;
    }

    public void setOpenBuy(Boolean openBuy) {
        this.openBuy = openBuy;
    }

    public String getClassSize() {
        return classSize;
    }

    public void setClassSize(String classSize) {
        this.classSize = classSize;
    }

    public Integer getOpenClassCondition() {
        return openClassCondition;
    }

    public void setOpenClassCondition(Integer openClassCondition) {
        this.openClassCondition = openClassCondition;
    }

    public String getMinClassSize() {
        return minClassSize;
    }

    public void setMinClassSize(String minClassSize) {
        this.minClassSize = minClassSize;
    }

    public Long getConfirmDate() {
        return confirmDate;
    }

    public void setConfirmDate(Long confirmDate) {
        this.confirmDate = confirmDate;
    }

    public Long getStartClassDate() {
        return startClassDate;
    }

    public void setStartClassDate(Long startClassDate) {
        this.startClassDate = startClassDate;
    }

    public Long getEndClassDate() {
        return endClassDate;
    }

    public void setEndClassDate(Long endClassDate) {
        this.endClassDate = endClassDate;
    }

    public ClassLocation getClassLocation() {
        return classLocation;
    }

    public void setClassLocation(ClassLocation classLocation) {
        this.classLocation = classLocation;
    }

    public List<SuitableLearnAgeItem> getSuitableLearnAgeItemList() {
        return suitableLearnAgeItemList;
    }

    public void setSuitableLearnAgeItemList(List<SuitableLearnAgeItem> suitableLearnAgeItemList) {
        this.suitableLearnAgeItemList = suitableLearnAgeItemList;
    }

    public List<SelectLearnTargetItem> getSelectLearnTargetItemList() {
        return selectLearnTargetItemList;
    }

    public void setSelectLearnTargetItemList(List<SelectLearnTargetItem> selectLearnTargetItemList) {
        this.selectLearnTargetItemList = selectLearnTargetItemList;
    }

    public SelectSuitablePeopleItem getSelectSuitablePeopleItem() {
        return selectSuitablePeopleItem;
    }

    public void setSelectSuitablePeopleItem(SelectSuitablePeopleItem selectSuitablePeopleItem) {
        this.selectSuitablePeopleItem = selectSuitablePeopleItem;
    }

    public List<SelectTagItem> getSelectTagItemList() {
        return selectTagItemList;
    }

    public void setSelectTagItemList(List<SelectTagItem> selectTagItemList) {
        this.selectTagItemList = selectTagItemList;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getPlatformDividend() {
        return platformDividend;
    }

    public void setPlatformDividend(String platformDividend) {
        this.platformDividend = platformDividend;
    }

    public String getCourseNumber() {
        return courseNumber;
    }

    public void setCourseNumber(String courseNumber) {
        this.courseNumber = courseNumber;
    }

    public List<TraingCard> getTraingCardList() {
        return traingCardList;
    }

    public void setTraingCardList(List<TraingCard> traingCardList) {
        this.traingCardList = traingCardList;
    }

    public String getSinglePrice() {
        return singlePrice;
    }

    public void setSinglePrice(String singlePrice) {
        this.singlePrice = singlePrice;
    }

    public CourseDescriptionModel getCourseDescriptionModel() {
        return courseDescriptionModel;
    }

    public void setCourseDescriptionModel(CourseDescriptionModel courseDescriptionModel) {
        this.courseDescriptionModel = courseDescriptionModel;
    }

    public CourseCover getCover() {
        return cover;
    }

    public void setCover(CourseCover cover) {
        this.cover = cover;
    }

    public CourseScheduleModel getCourseScheduleModel() {
        return courseScheduleModel;
    }

    public void setCourseScheduleModel(CourseScheduleModel courseScheduleModel) {
        this.courseScheduleModel = courseScheduleModel;
    }

    public int getOperationType() {
        return operationType;
    }

    public void setOperationType(int operationType) {
        this.operationType = operationType;
    }

    public String getSingleClassDuration() {
        return singleClassDuration;
    }

    public void setSingleClassDuration(String singleClassDuration) {
        this.singleClassDuration = singleClassDuration;
    }

    public List<GuaranteeItem> getGuaranteeItemList() {
        return guaranteeItemList;
    }

    public void setGuaranteeItemList(List<GuaranteeItem> guaranteeItemList) {
        this.guaranteeItemList = guaranteeItemList;
    }

    public static final class Builder {
        private String goodsId;
        private String title;
        private PublishInterestItem publishInterestItem;
        private Boolean openBuy;
        private String classSize;
        private Integer openClassCondition;
        private String minClassSize;
        private Long confirmDate;
        private Long startClassDate;
        private Long endClassDate;
        private ClassLocation classLocation;
        private List<SuitableLearnAgeItem> suitableLearnAgeItemList;
        private List<SelectLearnTargetItem> selectLearnTargetItemList;
        private SelectSuitablePeopleItem selectSuitablePeopleItem;
        private List<SelectTagItem> selectTagItemList;
        private String price;
        private String platformDividend;
        private String courseNumber;
        private List<TraingCard> traingCardList;
        private String singlePrice;
        private CourseDescriptionModel courseDescriptionModel;
        private CourseCover cover;
        private CourseScheduleModel courseScheduleModel;
        private int operationType;
        private String singleClassDuration;
        private List<GuaranteeItem> guaranteeItemList;

        private Builder() {
            goodsId = null;
            title = null;
            publishInterestItem = PublishInterestItem
                    .newBuilder()
                    .parent(PublishIndustryItem
                            .newBuilder()
                            .build())
                    .build();
            openBuy = true;
            classSize = null;
            openClassCondition = OPEN_CLASS_CONDITION_DEPEND_ON_OPEN_DATE;
            minClassSize = null;
            confirmDate = null;
            startClassDate = null;
            endClassDate = null;
            classLocation = null;
            suitableLearnAgeItemList = new LinkedList<>();
            selectLearnTargetItemList = new LinkedList<>();
            selectSuitablePeopleItem = null;
            selectTagItemList = new LinkedList<>();
            price = null;
            courseNumber = null;
            traingCardList = new LinkedList<>();
            singlePrice = null;
            cover = null;
            courseDescriptionModel = CourseDescriptionModel.newBuilder().build();
            courseScheduleModel = CourseScheduleModel.newBuilder().build();
            platformDividend = "";
            operationType = PublishUtil.OPERATION_TYPE_CREATE;
            singleClassDuration = null;
            guaranteeItemList = new LinkedList<>();
        }

        public Builder goodsId(String goodsId) {
            this.goodsId = goodsId;
            return this;
        }

        public Builder title(String title) {
            this.title = title;
            return this;
        }

        public Builder publishInterestItem(PublishInterestItem publishInterestItem) {
            this.publishInterestItem = publishInterestItem;
            return this;
        }

        public Builder openBuy(Boolean openBuy) {
            this.openBuy = openBuy;
            return this;
        }

        public Builder classSize(String classSize) {
            this.classSize = classSize;
            return this;
        }

        public Builder openClassCondition(Integer openClassCondition) {
            this.openClassCondition = openClassCondition;
            return this;
        }

        public Builder minClassSize(String minClassSize) {
            this.minClassSize = minClassSize;
            return this;
        }

        public Builder confirmDate(Long confirmDate) {
            this.confirmDate = confirmDate;
            return this;
        }

        public Builder startClassDate(Long startClassDate) {
            this.startClassDate = startClassDate;
            return this;
        }

        public Builder endClassDate(Long endClassDate) {
            this.endClassDate = endClassDate;
            return this;
        }

        public Builder classLocation(ClassLocation classLocation) {
            this.classLocation = classLocation;
            return this;
        }

        public Builder suitableLearnAgeItemList(List<SuitableLearnAgeItem> suitableLearnAgeItemList) {
            this.suitableLearnAgeItemList = suitableLearnAgeItemList;
            return this;
        }

        public Builder selectLearnTargetItemList(List<SelectLearnTargetItem> selectLearnTargetItemList) {
            this.selectLearnTargetItemList = selectLearnTargetItemList;
            return this;
        }

        public Builder selectSuitablePeopleItem(SelectSuitablePeopleItem selectSuitablePeopleItem) {
            this.selectSuitablePeopleItem = selectSuitablePeopleItem;
            return this;
        }

        public Builder selectTagItemList(List<SelectTagItem> selectTagItemList) {
            this.selectTagItemList = selectTagItemList;
            return this;
        }

        public Builder price(String price) {
            this.price = price;
            return this;
        }

        public Builder platformDividend(String platformDividend) {
            this.platformDividend = platformDividend;
            return this;
        }

        public Builder courseNumber(String courseNumber) {
            this.courseNumber = courseNumber;
            return this;
        }

        public Builder traingCardList(List<TraingCard> traingCardList) {
            this.traingCardList = traingCardList;
            return this;
        }

        public Builder singlePrice(String singlePrice) {
            this.singlePrice = singlePrice;
            return this;
        }

        public Builder courseDescriptionModel(CourseDescriptionModel courseDescriptionModel) {
            this.courseDescriptionModel = courseDescriptionModel;
            return this;
        }

        public Builder cover(CourseCover cover) {
            this.cover = cover;
            return this;
        }

        public Builder courseScheduleModel(CourseScheduleModel courseScheduleModel) {
            this.courseScheduleModel = courseScheduleModel;
            return this;
        }

        public Builder operationType(int operationType) {
            this.operationType = operationType;
            return this;
        }

        public Builder singleClassDuration(String singleClassDuration) {
            this.singleClassDuration = singleClassDuration;
            return this;
        }

        public Builder guaranteeItemList(List<GuaranteeItem> guaranteeItemList) {
            this.guaranteeItemList = guaranteeItemList;
            return this;
        }

        public TraingClassFormModel build() {
            return new TraingClassFormModel(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.goodsId);
        dest.writeString(this.title);
        dest.writeParcelable(this.publishInterestItem, flags);
        dest.writeValue(this.openBuy);
        dest.writeString(this.classSize);
        dest.writeValue(this.openClassCondition);
        dest.writeString(this.minClassSize);
        dest.writeValue(this.confirmDate);
        dest.writeValue(this.startClassDate);
        dest.writeValue(this.endClassDate);
        dest.writeParcelable(this.classLocation, flags);
        dest.writeTypedList(this.suitableLearnAgeItemList);
        dest.writeTypedList(this.selectLearnTargetItemList);
        dest.writeParcelable(this.selectSuitablePeopleItem, flags);
        dest.writeTypedList(this.selectTagItemList);
        dest.writeString(this.price);
        dest.writeString(this.platformDividend);
        dest.writeString(this.courseNumber);
        dest.writeTypedList(this.traingCardList);
        dest.writeString(this.singlePrice);
        dest.writeParcelable(this.courseDescriptionModel, flags);
        dest.writeParcelable(this.cover, flags);
        dest.writeParcelable(this.courseScheduleModel, flags);
        dest.writeInt(this.operationType);
        dest.writeString(this.singleClassDuration);
        dest.writeTypedList(this.guaranteeItemList);
    }

    protected TraingClassFormModel(Parcel in) {
        this.goodsId = in.readString();
        this.title = in.readString();
        this.publishInterestItem = in.readParcelable(PublishInterestItem.class.getClassLoader());
        this.openBuy = (Boolean) in.readValue(Boolean.class.getClassLoader());
        this.classSize = in.readString();
        this.openClassCondition = (Integer) in.readValue(Integer.class.getClassLoader());
        this.minClassSize = in.readString();
        this.confirmDate = (Long) in.readValue(Long.class.getClassLoader());
        this.startClassDate = (Long) in.readValue(Long.class.getClassLoader());
        this.endClassDate = (Long) in.readValue(Long.class.getClassLoader());
        this.classLocation = in.readParcelable(ClassLocation.class.getClassLoader());
        this.suitableLearnAgeItemList = in.createTypedArrayList(SuitableLearnAgeItem.CREATOR);
        this.selectLearnTargetItemList = in.createTypedArrayList(SelectLearnTargetItem.CREATOR);
        this.selectSuitablePeopleItem = in.readParcelable(SelectSuitablePeopleItem.class.getClassLoader());
        this.selectTagItemList = in.createTypedArrayList(SelectTagItem.CREATOR);
        this.price = in.readString();
        this.platformDividend = in.readString();
        this.courseNumber = in.readString();
        this.traingCardList = in.createTypedArrayList(TraingCard.CREATOR);
        this.singlePrice = in.readString();
        this.courseDescriptionModel = in.readParcelable(CourseDescriptionModel.class.getClassLoader());
        this.cover = in.readParcelable(CourseCover.class.getClassLoader());
        this.courseScheduleModel = in.readParcelable(CourseScheduleModel.class.getClassLoader());
        this.operationType = in.readInt();
        this.singleClassDuration = in.readString();
        this.guaranteeItemList = in.createTypedArrayList(GuaranteeItem.CREATOR);
    }

    public static final Parcelable.Creator<TraingClassFormModel> CREATOR = new Parcelable.Creator<TraingClassFormModel>() {
        @Override
        public TraingClassFormModel createFromParcel(Parcel source) {
            return new TraingClassFormModel(source);
        }

        @Override
        public TraingClassFormModel[] newArray(int size) {
            return new TraingClassFormModel[size];
        }
    };


    public static TraingClassFormModel parse(Moment moment, int operationType) {
        List<TagBackup> tagBackupList = moment.getTags();
        SelectSuitablePeopleItem selectSuitablePeopleItem = SelectSuitablePeopleItem.newBuilder().build();
        List<SelectLearnTargetItem> selectLearnTargetItemList = new LinkedList<>();
        List<SelectTagItem> selectTagItemList = new LinkedList<>();
        List<SuitableLearnAgeItem> suitableLearnAgeItemList = new LinkedList<>();
        PublishInterestItem publishInterestItem = PublishInterestItem.newBuilder().build();
        publishInterestItem.setParent(PublishIndustryItem.newBuilder().build());
        for (TagBackup tagBackup : tagBackupList) {
            if (tagBackup == null) continue;
            switch (tagBackup.getGroupType()) {
                case SetupUtil.GROUP_TYPE_LEARN_AGE:
                    suitableLearnAgeItemList.add(SuitableLearnAgeItem.newBuilder()
                            .id(tagBackup.getId())
                            .title(tagBackup.getName())
                            .build());
                    break;
                case SetupUtil.GROUP_TYPE_CATEGORY:
                    publishInterestItem.setId(tagBackup.getId());
                    publishInterestItem.setTitle(tagBackup.getName());
                    publishInterestItem.setParent(PublishIndustryItem.newBuilder()
                            .id(tagBackup.getSubGroupType())
                            .title(tagBackup.getSubGroupName())
                            .build());
                    break;
                case SetupUtil.GROUP_TYPE_SUITABLE_PEOPLE:
                    selectSuitablePeopleItem.setId(tagBackup.getId());
                    selectSuitablePeopleItem.setTitle(tagBackup.getName());
                    break;
                case SetupUtil.GROUP_TYPE_LEARN_TARGET:
                    selectLearnTargetItemList.add(SelectLearnTargetItem.newBuilder()
                            .id(tagBackup.getId())
                            .title(tagBackup.getName())
                            .build());
                    break;
                case SetupUtil.GROUP_TYPE_OTHER:
                    selectTagItemList.add(SelectTagItem.newBuilder()
                            .id(tagBackup.getId())
                            .name(tagBackup.getName())
                            .build());
                    break;
            }
        }
        List<GuaranteeItem> guaranteeItemList = new LinkedList<>();
        List<Guarantee> guaranteeList = moment.getDetailBackup().getGuarantee();
        for (Guarantee guarantee : guaranteeList) {
            guaranteeItemList.add(GuaranteeItem.newBuilder()
                    .id(guarantee.getId())
                    .title(guarantee.getName())
                    .content(guarantee.getDetail())
                    .build());
        }


        TrainingCourse trainingCourse = JSON.parseObject(moment.getMoreBackup(), TrainingCourse.class);
        List<TraingCard> traingCardList = new LinkedList<>();
        try {
            List<CardBackup> cardBackupList = trainingCourse.getBindCardBackup();
            for (CardBackup cardBackup : cardBackupList) {
                int traingCardType;
                switch (cardBackup.getCardType()) {
                    case Moment.TRAINING_CARD_TYPE_MEASURED_CARD:
                        traingCardType = TraingCard.TYPE_COUNT_CARD;
                        break;
                    case Moment.TRAINING_CARD_TYPE_RECHARGEABLE_CARD:
                        traingCardType = TraingCard.TYPE_PREPAID_CARD;
                        break;
                    case Moment.TRAINING_CARD_TYPE_TIME_CARD:
                        traingCardType = TraingCard.TYPE_TIME_CARD;
                        break;
                    default:
                        traingCardType = TraingCard.TYPE_COUNT_CARD;
                        break;
                }
                traingCardList.add(TraingCard.newBuilder()
                        .id(cardBackup.getId())
                        .type(traingCardType)
                        .title(cardBackup.getTitle())
                        .build());
            }
        } catch (Exception e) {

        }

        CourseDescriptionModel courseDescriptionModel = CourseDescriptionModel.newBuilder().build();
        try {
            courseDescriptionModel.setCourseCoverList(PublishUtil.convertContentToCourseCover(trainingCourse.getCoverSet()));
        } catch (Exception e) {

        }
        CourseCover defaultCover = null;
        for (CourseCover courseCover : courseDescriptionModel.getCourseCoverList()) {
            if (courseCover.isDefaultCover()) {
                defaultCover = courseCover;
                break;
            }
        }
        if (defaultCover == null) {
            defaultCover = CourseCover.newBuilder()
                    .imageUrl("")
                    .videoUrl("")
                    .needUpload(false)
                    .build();
        }

        try {
            courseDescriptionModel.setArticleNodeList(PublishUtil.convertContentToArticle(moment.getDetailBackup().getContent()));
        } catch (Exception e) {

        }
        CourseScheduleModel courseScheduleModel = CourseScheduleModel.newBuilder().build();
        try {
            courseScheduleModel.setArticleNodeList(PublishUtil.convertContentToArticle(trainingCourse.getTimetable()));
        } catch (Exception e) {

        }
        Integer openClassCondition = null;
        try {
            switch (trainingCourse.getTakeEffectCondition()) {
                case Moment.COURSE_TAKE_EFFECT_CONDITION_OPEN_DATE:
                    openClassCondition = TraingClassFormModel.OPEN_CLASS_CONDITION_DEPEND_ON_OPEN_DATE;
                    break;
                case Moment.COURSE_TAKE_EFFECT_CONDITION_POPULATION:
                    openClassCondition = TraingClassFormModel.OPEN_CLASS_CONDITION_DEPEND_ON_POPULATION;
                    break;
            }
        } catch (Exception e) {

        }

        ClassLocation classLocation;
        try {
            City city = DummyDataUtil.getCityById(moment.getCityId());
            classLocation = ClassLocation.newBuilder()
                    .city(city.getCity())
                    .province(city.getProvince())
                    .id(city.getId())
                    .build();
        } catch (Exception e) {
            classLocation = ClassLocation.newBuilder().build();
        }

        String goodsId;
        switch (operationType) {
            case PublishUtil.OPERATION_TYPE_CREATE:
            case PublishUtil.OPERATION_TYPE_COPY:
                goodsId = null;
                break;
            case PublishUtil.OPERATION_TYPE_EDIT:
                goodsId = moment.getId();
                break;
            default:
                goodsId = null;
                break;

        }

        return TraingClassFormModel.newBuilder()
                .goodsId(goodsId)
                .title(moment.getTitle())
                .publishInterestItem(publishInterestItem)
                .openBuy(moment.getLetBuy())
                .classSize(trainingCourse.getStudentMax() == null ? null : String.valueOf(trainingCourse.getStudentMax()))
                .openClassCondition(openClassCondition)
                .minClassSize(trainingCourse.getStudentMin() == null ? null : String.valueOf(trainingCourse.getStudentMin()))
                .confirmDate(trainingCourse.getConfirmStartClassDate())
                .startClassDate(trainingCourse.getStartDate())
                .endClassDate(trainingCourse.getEndDate())
                .classLocation(classLocation)
                .suitableLearnAgeItemList(suitableLearnAgeItemList)
                .selectLearnTargetItemList(selectLearnTargetItemList)
                .selectSuitablePeopleItem(selectSuitablePeopleItem)
                .selectTagItemList(selectTagItemList)
                .price(trainingCourse.getPrice() == null ? null : StringUtils.priceFormatEscapeRedundantTailZero(trainingCourse.getPrice()))
                .platformDividend(trainingCourse.getDivisionProportion() == null ? StringUtils.priceFormatEscapeRedundantTailZero(PublishUtil.MIN_PLATFORM_DIVIDEND * 100) : StringUtils.platformDividendFormat(trainingCourse.getDivisionProportion() * 100))
                .courseNumber(trainingCourse.getClassCount() == null ? null : String.valueOf(trainingCourse.getClassCount()))
                .traingCardList(traingCardList)
                .singlePrice(trainingCourse.getUnitPrice() == null ? null : StringUtils.priceFormatEscapeRedundantTailZero(trainingCourse.getUnitPrice()))
                .courseDescriptionModel(courseDescriptionModel)
                .cover(defaultCover)
                .courseScheduleModel(courseScheduleModel)
                .operationType(operationType)
                .singleClassDuration(trainingCourse.getDruationPerClass() == null ? null : String.valueOf(trainingCourse.getDruationPerClass()))
                .guaranteeItemList(guaranteeItemList)
                .build();
    }

}
